| Conditions | 2 |
| Total Lines | 8 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | 7 | import { Injectable, UnauthorizedException } from '@nestjs/common'; |
|
| 22 | |||
| 23 | async validate(payload: JwtPayload) { |
||
| 24 | // this is not stateless, as we query the db. This can be refactored to be stateless, the token contains all user data. |
||
| 25 | 30 | const user = await this.authService.validateUserById(payload.sub); |
|
| 26 | 30 | if (!user) { |
|
| 27 | 2 | throw new UnauthorizedException(); |
|
| 28 | } |
||
| 29 | 28 | return user; |
|
| 30 | } |
||
| 32 |